﻿using MVCManage.Model;
using MVCManage.Model.Base;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MVCMamage.DAL;
namespace MVCManage.BLL
{
    public class DepartmentBLL : BaseBLL<Department>
    {
        public override void SetDal()
        {
            Dal =new DepartmentDAL();
        }
        public List<Department> GetRolesPagelist(string name, int page, int size, out int count)
        {
            var list = Dal.Query();
            if (!string.IsNullOrWhiteSpace(name))
            {
                list = list.Where(n => n.deptName.Contains(name));
            }
            count = list.Count();
            var pagelist = list.OrderBy(n => n.deptID).Skip((page - 1) * size).Take(size);
            return pagelist.ToList();

        }
        public bool Delete(int id)
        {
            var zhi = Dal.Query().Where(n => n.deptID== id).FirstOrDefault();
            Dal.Delete(zhi);
            return Dal.SaveChanges();
        }
        public bool Deletes(int[] ids)
        {
            var zhi = Dal.Query().Where(n => ids.Contains(n.deptID)).ToList();
            Dal.Deletes(zhi);
            return Dal.SaveChanges();
        }
    }
}
